<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<html>
<head> <title>Delete User Screen</title>
</head>
<body>
<center>
<p><font color="#0080FF" size="25">Delete User Screen</font></p>
<%
       try
       {
		if(session.getAttribute("logged_in") == "true")
		{
			
			if(session.getAttribute("user_level") == "administrator")
			{
				out.println("<br>You selected screen id: '" + request.getParameter("screen_id") + "'<br>");


			String DRIVER = "com.mysql.jdbc.Driver";
			Class.forName(DRIVER);
	
			Connection con=null;
			ResultSet rst=null;
			Statement stmt=null;
				
	
        	        String url="jdbc:mysql://ecstiger.cs.andrews.edu/d562_2010_01?user=u562_2010_01&password=YPJ8f4We";
			con=DriverManager.getConnection(url);
			stmt=con.createStatement();

			String sqle = "DELETE FROM screen_owners WHERE screen_id = '" + request.getParameter("screen_id") + "' AND user_id = '"+ request.getParameter("user_id") + "';";
			stmt=con.createStatement();

			if(stmt.executeUpdate(sqle) == 1)
			{				
				out.println("<p><h1>This screen is NOT available for this User any more.!! </h1></p>");
			}
			else
			{
				out.println("<p><h1>The screen is NOT Deleted!! </h1></p>");
			}	
		rst.close();
		stmt.close();
		con.close();
		}
		
		}
		else
		{
			out.println("Not Logged In");
		}
       }
       catch(Exception e)
       {
          // out.println(e);
       }	
%>
<br><a href="menu.jsp">Main Menu</a>


</center>
</body>
</table>
</center>
</div>
</body>
</html>
